Skip to content

Add delegated signing seam#59

Open
aidangarske wants to merge 4 commits into
wolfSSL:mainfrom
aidangarske:tfm-integration
Open

Add delegated signing seam#59
aidangarske wants to merge 4 commits into
wolfSSL:mainfrom
aidangarske:tfm-integration

Conversation

@aidangarske

@aidangarske aidangarske commented Jul 17, 2026

Copy link
Copy Markdown
Member

Adds WOLFCOSE_ENABLE_EXT_SIGN, letting a caller supply a signature callback so the private key never enters wolfCOSE. Needed for TF-M, where the attestation key stays in the crypto partition and signing goes over psa_sign_hash. Useful for any HSM backed key.

Wired into both wc_CoseSign1_Sign and wc_CoseSign_Sign. With a callback set rng may be NULL; for wc_CoseSign_Sign that holds when every signer delegates.

Off by default, no functional change when disabled.

Also addresses the Copilot review on this PR:

  • Validate the delegated signature length by algorithm, not key->kty, so a signer that leaves kty/crv unset cannot slip a malformed ECDSA/ML-DSA length into the message.
  • Gate the ext-sign algorithm set on the build's WOLFCOSE_HAVE_* macros, so delegated signing cannot emit EdDSA/ML-DSA (or any algorithm) the build has disabled.
  • wc_CoseSign_Sign no longer rejects rng == NULL when all signers use a callback.

Adds a delegated-signing unit test (make ext-sign-test): delegated sign then local verify, wrong-length rejection, and NULL-callback guards.

Testing: full suite passes with the feature on and off. Verified end to end in TF-M v2.3.0 on QEMU mps2-an521, where the attestation partition signs the EAT through the callback to wolfPSA and the tf-m-tests regression suite passes with 0 failures. Paired OSP patch adds the TF-M side.

  • Skoll still needs run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in “delegated/external signing” seam so callers can provide a signature callback (e.g., TF-M / PSA / HSM-backed keys) and keep private key material outside of wolfCOSE, integrating this into COSE_Sign1 and COSE_Sign.

Changes:

  • Introduces WOLFCOSE_ENABLE_EXT_SIGNWOLFCOSE_EXT_SIGN build-time gate and public WOLFCOSE_SIGN_CB callback type.
  • Adds wc_CoseKey_SetExtSigner() and plumbs the callback-driven signing path into wc_CoseSign1_Sign() and wc_CoseSign_Sign().
  • Extends failure-injection points to cover external signer failures.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/force_failure.h Adds a failure-injection enum for external signer callbacks.
src/wolfcose.c Implements delegated signing, callback invocation, and integrates it into Sign1/Sign signing flows.
src/wolfcose_internal.h Declares internal wolfCose_ExtSign() helper under the feature gate.
include/wolfcose/wolfcose.h Adds public callback typedef, extends WOLFCOSE_KEY (feature-gated), and exports wc_CoseKey_SetExtSigner().
include/wolfcose/settings.h Adds the opt-in configuration macro and a build-time sanity check for signing enablement.

Comment thread src/wolfcose.c Outdated
Comment thread src/wolfcose.c
Comment thread src/wolfcose.c
@aidangarske
aidangarske marked this pull request as ready for review July 21, 2026 22:11
@aidangarske aidangarske self-assigned this Jul 21, 2026
…thm, gate ext-sign algorithms, allow NULL rng for delegated COSE_Sign, and add a delegated-signing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants